home *** CD-ROM | disk | FTP | other *** search
/ Aminet 39 / Aminet 39 (2000)(Schatztruhe)[!][Oct 2000].iso / Aminet / misc / emu / flamingo.lha / Flamingo / sources / ecs-delta.asm < prev    next >
Encoding:
Assembly Source File  |  1999-07-01  |  8.0 KB  |  484 lines

  1. ; ECS-Delta
  2. ; External Video Driver for
  3. ; Flaming Plus/4 emulator for the Amiga
  4. ;
  5. ; version 1.0
  6.  
  7.     MACHINE    68020
  8.  
  9.         INCDIR    Include:
  10.  
  11.     INCLUDE exec/types.i
  12.     INCLUDE    exec/memory.i
  13.     INCLUDE    exec/exec_lib.i
  14.     INCLUDE    utility/tagitem.i
  15.     INCLUDE    intuition/intuition.i
  16.     INCLUDE    intuition/intuition_lib.i
  17.     INCLUDE    intuition/screens.i
  18.     INCLUDE    graphics/graphics_lib.i
  19.     INCLUDE graphics/modeid.i
  20.     INCLUDE    graphics/rastport.i
  21.     INCLUDE    macros.i
  22.  
  23. ;*** Handler structure
  24.  
  25.  STRUCTURE vxd_handler,0
  26.   LONG intuibase
  27.   LONG graphbase
  28.   LONG myscr
  29.   LONG mywin
  30.   LONG planes
  31.   WORD xsize
  32.   WORD ysize
  33.   LONG chunkysize
  34.   LONG palette
  35.   LONG emuscr
  36.   LONG delta
  37.   WORD bytesperrow
  38.  LABEL    vxd_handler_SIZEOF
  39.  
  40.  STRUCTURE c2p,4
  41.   LONG C2PChunkyBufferAddress
  42.   LONG C2PDeltaBufferAddress
  43.   LONG C2PPlanarBufferAddress
  44.   LONG C2PChunkyBufferWidth
  45.   LONG C2PChunkyBufferWidthDiv8
  46.   LONG C2PChunkyBufferHeight
  47.   LONG C2PChunkyBufferSize
  48.   LONG C2PBitplaneByteWidth
  49.  LABEL c2p_SIZEOF
  50.  
  51. JSRLIB    MACRO
  52.     jsr    _LVO\1(a6)
  53.     ENDM
  54.  
  55. ;*** Let's begin
  56.  
  57.     moveq.l    #0,d0
  58.     rts
  59.  
  60.     dc.b "FLAMINGOXVD"
  61.     dc.b "1"
  62.  
  63.     dc.l Name
  64.     dc.l Author
  65.     dc.w 1
  66.     dc.w 1
  67.  
  68.     dc.l drv_Init
  69.     dc.l drv_Done
  70.     dc.l 0            ;nothing to configure
  71. ;    dc.l drv_Configure
  72.     dc.l drv_OpenScreen
  73.     dc.l drv_CloseScreen
  74.     dc.l drv_Refresh
  75.  
  76. Name:    dc.b    "ECS-Delta External Video Driver",0
  77. Author:    dc.b    "Álmos Rajnai (original C2P by Ferenc Zavacki)",0
  78.  
  79.     EVEN
  80.  
  81. ;*** Functions
  82.  
  83. drv_Init:
  84.     movem.l    a0-a1,-(sp)    ;Saving infos
  85.     move.l  4.w,a6        ;Alloc memory for handler
  86.     move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  87.     move.l    #vxd_handler_SIZEOF,d0
  88.     JSRLIB    AllocVec
  89.     movem.l    (sp)+,a0-a1    ;Recover infos
  90.         cmp.l    #0,d0
  91.     beq.b    .1        ;No mem
  92.     movea.l    d0,a2
  93.         move.l    (a0),graphbase(a2)    ;Saving graphics.library base
  94.         move.l    8(a0),intuibase(a2)    ;Saving intuition.library base
  95. .1    move.l    #err_nomem,d1        ;Ignored, if D0 not 0
  96.     rts                ;Result in D0 available for now
  97.  
  98. drv_Done:
  99.     movea.l    a0,a1
  100.     cmpa.l    #0,a1
  101.     beq.b    .1
  102.     move.l    4.w,a6
  103.     JSRLIB    FreeVec        ;Deallocate handler
  104. .1
  105.     rts
  106.  
  107. ;drv_Configure:        -> Nothing to configure
  108. ;    rts
  109.  
  110. drv_OpenScreen:
  111.     movea.l a0,a5
  112.     move.w    (a1)+,xsize(a5)
  113.     move.w    (a1)+,ysize(a5)
  114.  
  115.     moveq.l    #0,d0
  116.     move.l    d0,d1
  117.     move.w    xsize(a5),d0
  118.     move.w    ysize(a5),d1
  119.     mulu.w    d1,d0
  120.     move.l    d0,chunkysize(a5)
  121.     move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  122.     move.l    4.w,a6
  123.     JSRLIB    AllocVec
  124.     move.l    d0,emuscr(a5)        ;allocating emulator screen
  125.     tst.l    d0
  126.     beq.w    .1
  127.  
  128.     move.l    chunkysize(a5),d0
  129.     move.l    #MEMF_PUBLIC|MEMF_CLEAR,d1
  130.     move.l    4.w,a6
  131.     JSRLIB    AllocVec
  132.     move.l    d0,delta(a5)        ;allocating delta buffer
  133.     tst.l    d0
  134.     beq.w    .1
  135.  
  136.     move.w    xsize(a5),width+2
  137.     move.w    ysize(a5),height+2
  138.         suba.l    a0,a0            ;No newscreen stuct
  139.         lea    scrtags,a1
  140.     movea.l    intuibase(a5),a6
  141.     JSRLIB    OpenScreenTagList
  142.     move.l    d0,myscr(a5)
  143.     beq.w    .1
  144.     move.l    d0,wscr
  145.     move.l    d0,a0
  146.     lea    sc_RastPort(a0),a0
  147.     movea.l    rp_BitMap(a0),a0
  148.     move.l    #BMA_FLAGS,d1
  149.     movea.l    graphbase(a5),a6
  150.     JSRLIB    GetBitMapAttr
  151.     and.l    #BMF_STANDARD|BMF_INTERLEAVED,d0
  152.     cmp.l    #BMF_STANDARD|BMF_INTERLEAVED,d0
  153.     beq.b    .3
  154.     movea.l    intuibase(a5),a6
  155.     move.l    myscr(a5),a0
  156.     JSRLIB    CloseScreen
  157.     moveq.l    #0,d0
  158.     move.l    d0,myscr(a5)
  159.     bra.b    .1
  160.  
  161. .3    move.w    xsize(a5),wwidth+2
  162.     move.w    ysize(a5),wheight+2
  163.     suba.l    a0,a0
  164.     lea    wintags,a1
  165.     movea.l    intuibase(a5),a6
  166.     JSRLIB    OpenWindowTagList
  167.     move.l    d0,mywin(a5)
  168.     beq.b    .1
  169.     movea.l    d0,a1
  170.     move.l  wd_RPort(a1),a0
  171.     move.l    rp_BitMap(a0),a0
  172.     move.l    bm_Planes(a0),planes(a5)
  173.     move.w    bm_BytesPerRow(a0),d0
  174.     and.l    #$ffff,d0
  175.     moveq.l    #3,d1
  176.     divu.w    d1,d0
  177.     move.w    d0,bytesperrow(a5)
  178.     move.l  wd_UserPort(a1),d0    ;IDCMP port
  179.     move.l    emuscr(a5),d2        ;chunky buffer
  180.  
  181. .1    move.l    #err_noscr,d1
  182.     moveq.l    #0,d3            ;no chunky modulo
  183.     rts
  184.  
  185. drv_CloseScreen:
  186.     move.l    a0,a5
  187.     move.l    intuibase(a5),a6
  188.     move.l    mywin(a5),a0
  189.     cmpa.l    #0,a0
  190.     beq.b    .1
  191.     JSRLIB    CloseWindow
  192.  
  193. .1    move.l    myscr(a5),a0
  194.     cmpa.l    #0,a0
  195.     beq.b    .2
  196.     JSRLIB    CloseScreen
  197.  
  198. .2    movea.l    emuscr(a5),a1
  199.         cmpa.l    #0,a1
  200.     beq.b    .4
  201.     move.l    4.w,a6
  202.     JSRLIB    FreeVec        ;Deallocate chunky buffer
  203.  
  204. .4    movea.l    delta(a5),a1
  205.         cmpa.l    #0,a1
  206.     beq.b    .3
  207.     move.l    4.w,a6
  208.     JSRLIB    FreeVec        ;Deallocate delta buffer
  209.  
  210. .3    moveq.l    #0,d0
  211.     move.l    d0,emuscr(a5)    ;They were already freed
  212.     move.l    d0,delta(a5)
  213.     move.l    d0,myscr(a5)
  214.     move.l    d0,mywin(a5)
  215.  
  216.     rts
  217.  
  218. drv_Refresh:
  219.     suba.l    #c2p_SIZEOF,a7        ;Storing all data on stack
  220.  
  221.     move.l    (emuscr,a0),(C2PChunkyBufferAddress,a7)
  222.     move.l    (delta,a0),(C2PDeltaBufferAddress,a7)
  223.     move.l    (planes,a0),(C2PPlanarBufferAddress,a7)
  224.     move.l    (delta,a0),(emuscr,a0)            ;exchange chunky and
  225.     move.l    (C2PChunkyBufferAddress,a7),(delta,a0)    ;delta buffer
  226.  
  227.     moveq.l    #0,d0
  228.     move.w    (xsize,a0),d0
  229.     move.l    d0,(C2PChunkyBufferWidth,a7)
  230.     lsr.l    #3,d0
  231.     move.l    d0,(C2PChunkyBufferWidthDiv8,a7)
  232.     move.w    (ysize,a0),d0
  233.     move.l    d0,(C2PChunkyBufferHeight,a7)
  234.     move.w    (bytesperrow,a0),d0
  235.     move.l    d0,(C2PBitplaneByteWidth,a7)
  236.     move.l    (chunkysize,a0),(C2PChunkyBufferSize,a7)
  237.  
  238.         move.l  (C2PChunkyBufferAddress,a7),a0
  239.     move.l    (C2PDeltaBufferAddress,a7),a1
  240.         move.l  (C2PChunkyBufferSize,a7),d0
  241.         lea     (a0,d0.L),a3
  242.  
  243.         move.l  (C2PPlanarBufferAddress,a7),a2
  244.  
  245.         move.l  (C2PBitplaneByteWidth,a7),D7
  246.  
  247. .12    move.l    (C2PChunkyBufferWidth,a7),d6
  248.     lsr.l    #5,d6
  249.  
  250. .11    cmp.l    (a0)+,(a1)+
  251.     bne.b    .1
  252.     cmp.l    (a0)+,(a1)+
  253.     bne.b    .2
  254.     cmp.l    (a0)+,(a1)+
  255.     bne.b    .3
  256.     cmp.l    (a0)+,(a1)+
  257.     bne.b    .4
  258.     cmp.l    (a0)+,(a1)+
  259.     bne.b    .5
  260.     cmp.l    (a0)+,(a1)+
  261.     bne.b    .6
  262.     cmp.l    (a0)+,(a1)+
  263.     bne.b    .7
  264.     cmp.l    (a0)+,(a1)+
  265.     bne.b    .8
  266.  
  267. .10    addq.l    #4,a2
  268.  
  269.     subq.l    #1,d6
  270.     bne.b    .11
  271.  
  272.     suba.l    (C2PChunkyBufferWidthDiv8,a7),a2
  273.     lea    (a2,d7.l*8),a2
  274.     sub.l    d7,a2
  275.  
  276.     cmp.l    a0,a3
  277.     bne.b    .12
  278.  
  279.  
  280.     move.l    C2PDeltaBufferAddress(a7),d0    ;giving back chunky buffer
  281.         adda.l    #c2p_SIZEOF,a7            ;changed to delta buffer
  282.     
  283.         rts
  284.  
  285. .1    subq.l    #1*4,a0
  286.     add.l    #7*4,a1
  287.     bra.b    .9
  288.  
  289. .2    subq.l    #2*4,a0
  290.     add.l    #6*4,a1
  291.     bra.b    .9
  292.  
  293. .3    sub.l    #3*4,a0
  294.     add.l    #5*4,a1
  295.     bra.b    .9
  296.  
  297. .4    sub.l    #4*4,a0
  298.     add.l    #4*4,a1
  299.     bra.b    .9
  300.  
  301. .5    sub.l    #5*4,a0
  302.     add.l    #3*4,a1
  303.     bra.b    .9
  304.  
  305. .6    sub.l    #6*4,a0
  306.     addq.l    #2*4,a1
  307.     bra.b    .9
  308.  
  309. .7    sub.l    #7*4,a0
  310.     addq.l    #1*4,a1
  311.     bra.b    .9
  312.  
  313. .8    sub.l    #8*4,a0
  314.     add.l    #0*4,a1
  315.  
  316. .9    move.l    #$0F0F0F0F,d5
  317.  
  318.     move.l    (a0)+,d0
  319.     and.l    d5,d0
  320.     lsl.l    #4,d0
  321.     move.l    (a0)+,d1
  322.     and.l    d5,d1
  323.     or.l    d1,d0
  324.  
  325.     move.l    (a0)+,d1
  326.     and.l    d5,d1
  327.     lsl.l    #4,d1
  328.     move.l    (a0)+,d2
  329.     and.l    d5,d2
  330.     or.l    d2,d1
  331.  
  332.     move.l    (a0)+,d2
  333.     and.l    d5,d2
  334.     lsl.l    #4,d2
  335.     move.l    (a0)+,d3
  336.     and.l    d5,d3
  337.     or.l    d3,d2
  338.  
  339.     move.l    (a0)+,d3
  340.     and.l    d5,d3
  341.     lsl.l    #4,d3
  342.     move.l    (a0)+,d4
  343.     and.l    d5,d4
  344.     or.l    d4,d3
  345.  
  346.     move.w    d2,d4
  347.     move.w    d0,d2
  348.     swap    d2
  349.     move.w    d2,d0
  350.     move.w    d4,d2
  351.  
  352.     move.w    d3,d4
  353.     move.w    d1,d3
  354.     swap    d3
  355.     move.w    d3,d1
  356.     move.w    d4,d3
  357.  
  358.     move.l    #$00FF00FF,d5
  359.  
  360.     move.l    d1,d4
  361.     lsr.l    #8,d4
  362.     eor.l    d0,d4
  363.     and.l    d5,d4
  364.     eor.l    d4,d0
  365.     lsl.l    #8,d4
  366.     eor.l    d4,d1
  367.  
  368.     move.l    d3,d4
  369.     lsr.l    #8,d4
  370.     eor.l    d2,d4
  371.     and.l    d5,d4
  372.     eor.l    d4,d2
  373.     lsl.l    #8,d4
  374.     eor.l    d4,d3
  375.  
  376.     move.l    #$33333333,d5
  377.  
  378.     move.l    d2,d4
  379.     lsr.l    #2,d4
  380.     eor.l    d0,d4
  381.     and.l    d5,d4
  382.     eor.l    d4,d0
  383.     lsl.l    #2,d4
  384.     eor.l    d4,d2
  385.  
  386.     move.l    d3,d4
  387.     lsr.l    #2,d4
  388.     eor.l    d1,d4
  389.     and.l    d5,d4
  390.     eor.l    d4,d1
  391.     lsl.l    #2,d4
  392.     eor.l    d4,d3
  393.  
  394.     move.l    #$55555555,d5
  395.  
  396.     move.l    d1,d4
  397.     lsr.l    #1,d4
  398.     eor.l    d0,d4
  399.     and.l    d5,d4
  400.     eor.l    d4,d0
  401.     lsl.l    #1,d4
  402.     eor.l    d4,d1
  403.  
  404.     move.l    d1,(a2,d7.l*2)
  405.  
  406.     move.l    d3,d4
  407.     lsr.l    #1,d4
  408.     eor.l    d2,d4
  409.     and.l    d5,d4
  410.     eor.l    d4,d2
  411.     lsl.l    #1,d4
  412.     eor.l    d4,d3
  413.  
  414.     move.l    d0,a4
  415.     move.l    d2,a5
  416.     move.l    d3,a6
  417.  
  418.     lsl.l    #2,d7
  419.     sub.l    d7,a2
  420.     lsr.l    #2,d7
  421.  
  422.     bra.w    .10
  423.  
  424.  
  425.     SECTION    structs,data
  426.  
  427. ;*** Constants
  428.  
  429. scrtags:
  430.     dc.l    SA_Width
  431. width:    dc.l    0
  432.     dc.l    SA_Height
  433. height:    dc.l    0
  434.     dc.l    SA_Depth,3
  435.     dc.l    SA_Colors32,palette32
  436.     dc.l    SA_Title,scrtitle
  437.     dc.l    SA_ShowTitle,FALSE
  438.     dc.l    SA_DisplayID,LORES_KEY
  439.     dc.l    SA_Interleaved,TRUE
  440.     dc.l    SA_Type,CUSTOMSCREEN
  441.     dc.l    SA_AutoScroll,TRUE
  442.     dc.l    SA_Overscan,OSCAN_STANDARD
  443.     dc.l    SA_Quiet,TRUE
  444.     dc.l    TAG_DONE
  445.  
  446. wintags:
  447.     dc.l    WA_Left,0
  448.     dc.l    WA_Top,0
  449.     dc.l    WA_Width
  450. wwidth:    dc.l    0
  451.     dc.l    WA_Height
  452. wheight:    dc.l    0
  453.     dc.l    WA_IDCMP,IDCMP_RAWKEY
  454.     dc.l    WA_Title,0
  455.     dc.l    WA_Backdrop,TRUE
  456.     dc.l    WA_RMBTrap,TRUE
  457.     dc.l    WA_Borderless,TRUE
  458.     dc.l    WA_NoCareRefresh,TRUE
  459.     dc.l    WA_CustomScreen
  460. wscr:    dc.l    0
  461.     dc.l    WA_SimpleRefresh,TRUE
  462.     dc.l    WA_Activate,TRUE
  463.     dc.l    TAG_DONE
  464.  
  465. scrtitle:    dc.b    'Flamingo Plus/4 emulator screen',0
  466. ;*** Errors
  467.  
  468. err_nomem:
  469.     dc.b    'Run out of memory',0
  470. err_noscr:
  471.     dc.b    'Cannot open screen',0
  472.  
  473.     EVEN
  474.  
  475. palette32:
  476.     dc.w    8,0
  477.  
  478. offs    SET    $30
  479.     REPT    8
  480.     dc.l    offs<<24,offs<<24,offs<<24
  481. offs    SET    offs+$1a
  482.     ENDR
  483.  
  484.